/*
 * @lc app=leetcode.cn id=62 lang=javascript
 *
 * [62] 不同路径
 */

// @lc code=start
/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var uniquePaths = function (m, n) {
  const curLine = new Array(m).fill(new Array(n).fill(0));

  for (let x = 0; x < m; x++) curLine[x][0] = 1;
  for (let x = 0; x < n; x++) curLine[0][x] = 1;
  // 初始值易错
  for (let i = 1; i < m; i++) {
    for (let j = 1; j < n; j++) {
      curLine[i][j] = curLine[i - 1][j] + curLine[i][j - 1];
    }
  }
  return curLine[m - 1][n - 1];
};
// @lc code=end
